package com.borya.action.server;

import com.borya.util.AsyncUtils;
import org.apache.log4j.Logger;

import com.borya.action.BaseAction;
import com.borya.framework.annotation.Action;
import com.borya.framework.annotation.Autowired;
import com.borya.framework.annotation.JsonResult;
import com.borya.framework.annotation.UrlMapping;
import com.borya.framework.core.ServerRequest;
import com.borya.framework.core.ServerResponse;
import com.borya.service.server.AutoResourcesService;
import com.borya.statuscode.StatusCode;


@UrlMapping("/s/autoResource/")
@Action
public class AutoResourceAction extends BaseAction{
	
	private Logger log = Logger.getLogger(getClass());
	
	@Autowired("autoResourcesServiceImpl")
	private AutoResourcesService autoService;
	
	public AutoResourcesService getAutoService() {
		return autoService;
	}

	public void setAutoService(AutoResourcesService autoService) {
		this.autoService = autoService;
	}

	@UrlMapping("ready")
	@JsonResult
	public String ready(ServerRequest request,ServerResponse response) {
		log.info("RECV :"+request.text());
		AsyncUtils.executor().execute(()->{
			getAutoService().startTask();
		});

		return StatusCode.SUCCESS.toJSON();
	}
}
